import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/Login'
import Index from "@/components/Index"
import Home from '@/components/Home'
import SafeWarring from '@/components/SafeWarring'
import Fence from '@/components/Fence'
import Device from '@/components/Device'
import User from '@/components/User'
import UserInfo from '@/components/UserInfo'
import SafeUser from '@/components/SafeUser'
import Cone from '@/components/Cone'
import Capital from '@/components/Capital'

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)


export default new Router({
  routes: [
    {
      path: '/login',
      name: 'login',
      component:Login,
    },
    {
      path: '/',
      name: 'index',
      component: Index,
      meta: { requiresAuth: true },
      children:[
        {
          path: '/',
          name: '/',
          component: Home,
          meta: { requiresAuth: true }
        },
        {
          path: '/safeWarring',
          name: 'Safe',
          component: SafeWarring,
          meta: { requiresAuth: true }
        },
        {
          path: '/fence',
          name: 'Fence',
          component: Fence
        },
        {
          path: '/device',
          name: 'Device',
          component: Device
        },
        {
          path: '/capital',
          name: 'Device',
          component: Capital
        },
        {
          path: '/cone',
          name: 'Device',
          component: Cone
        },
        {
          path: '/user',
          name: 'User',
          component: User
        },
        {
          path: '/userInfo',
          name: 'UserInfo',
          component: UserInfo
        },
        {
          path: '/safeUser',
          name: 'Safe',
          component: SafeUser
        }
      ]
    },
  ]
})
